<template>
  <View class="container">
    <navigation-bar @onBack="onBack()" :navigationStyle="{ background: '#51DBB6' }" />
    <scroll-view scroll-y class="scroll-view" :style="{height: 'calc(100% - ' + contentTop +')'}">
      <image mode="widthFix" :src="`${imgBasePath}newtask/to-store-guide.png`" class="to-store"></image>
    </scroll-view>
  </View>
</template>
<script>
import navigationBar from "./components/navigation-bar.vue";
import { imgBasePath, trackingHost } from "@/common/config";
export default {
  name: "toStore",
  components: {
    navigationBar
  },
  data() {
    return {
      contentTop: uni.getStorageSync('menuInfo').contentTop,
      imgBasePath,
      startTime: Date.parse(new Date()),
    }
  },
  onload() {
    this.checkinStoreTask("impression")
  },
  onUnload() {
    const endTime = Date.parse(new Date());
    const st = (endTime - this.startTime) / 1000;
    this.checkinStoreTask("sessionTime", st);
  },
  methods: {
    checkinStoreTask(event, st) {
      const { unionid, openid } = uni.getStorageSync("userInfo");
      const storeId = uni.getStorageSync("storeId");
      const params = {
        oid: openid,
        uid: unionid,
        sid: storeId,
        ts: Date.parse(new Date()) / 1000,
        event,
        page: "checkinStoreTask",
        st,
      }
      this.$request("event-tracking/user", { host: trackingHost, params })
        .catch(() => { })
    },
    onBack() {
      uni.navigateBack();
    },
  },
}
</script>
<style lang="scss" scoped>
.container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.scroll-view {
  flex: 1;
}

.to-store {
  top: -5rpx;
  width: 100%;
}
</style>